<?php
global $config;

$op = @ $_REQUEST["op"];

                    //ID            //FORM                      //LIST              //CONTROLLER
$valids = array(    //MÓDULO 1
                    "cad-clie" => array(FORMS."cad-clie.php", LISTS."cad-clie.php", "cliente"),
                    "cad-prod" => array(FORMS."cad-prod.php", LISTS."cad-prod.php", "produto"),
                    "cad-func" => array(FORMS."cad-func.php", LISTS."cad-func.php", "funcionario"),
                    "cad-labo" => array(FORMS."cad-labo.php", LISTS."cad-labo.php", "laboratorio"),
                    "cad-loja" => array(FORMS."cad-loja.php", LISTS."cad-loja.php", "loja"),
                    "cad-regi" => array(FORMS."cad-regi.php", LISTS."cad-regi.php", "regiao"),
                    "cad-loca" => array(FORMS."cad-loca.php", LISTS."cad-loca.php", "localidade"),
                    "cad-rota" => array(FORMS."cad-rota.php", LISTS."cad-rota.php", "rota"),
                    "cad-marc" => array(FORMS."cad-marc.php", LISTS."cad-marc.php", "produto"),
                    "cad-tipo" => array(FORMS."cad-tipo.php", LISTS."cad-tipo.php", "produto"),
                    //MÓDULO 2
                    "cad-orde" => array(FORMS."cad-orde.php", LISTS."cad-orde.php", "ordemServico"), 
                    "cad-vend" => array(FORMS."cad-vend.php", LISTS."cad-vend.php", "venda"),
		);

define("FORM_IDX", 0);
define("LIST_IDX", 1);
define("CONTROLLER_IDX", 2);

if(!empty($valids[$op])){
    if(isset($valids[$op][CONTROLLER_IDX]))
        $config->loadCurrentController($valids[$op][CONTROLLER_IDX]);
    if(isset($valids[$op][FORM_IDX]) && file_exists($valids[$op][FORM_IDX])) {
        echo "<div class='mini-content'>";
            include_once $valids[$op][FORM_IDX];
        echo "</div><br/>";
        
    }
    if(isset($valids[$op][LIST_IDX]) && file_exists($valids[$op][LIST_IDX])){
        echo "<div class='mini-content list-mini-content' >";
            include_once $valids[$op][LIST_IDX];
        echo "</div><br/>";
    }
    $openMode = $config->filter(OPEN_CAD);
    if(!empty($openMode)){
        $config->addJSDependencie(JS_OPEN_CAD);
    }
}
?>
